/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.basics.editor.gui.view.internal.panel;

import java.awt.Component;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.rmi.server.UID;

import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;

import com.genia.toolbox.basics.editor.gui.AbstractGUI;
import com.genia.toolbox.basics.editor.gui.view.internal.AbstractDocumentInternalFrame;
import com.genia.toolbox.basics.editor.model.document.Element;
import com.genia.toolbox.basics.editor.model.document.ElementType;

/**
 * View of an element.
 * 
 * @param <G>
 *          The generic gui.
 * @param <I>
 *          The generic internal frame.
 * @param <E>
 *          The generic element.
 * @param <T>
 *          The generic type.
 */
public interface ElementViewPanel<G extends AbstractGUI<?, ?, ?, ?, E, ?>, I extends AbstractDocumentInternalFrame<G, ?, ?, E, ?>, E extends Element<T>, T extends ElementType>
    extends MouseListener, ActionListener
{

  /**
   * Initialise the view.
   */
  public void initialise();



  /**
   * Create the common panel.
   * 
   * @return the common panel.
   */
  public JPanel createCommonPanel();



  /**
   * Create the specific panel.
   * 
   * @return the specific panel.
   */
  public JPanel createSpecificPanel();



  /**
   * Create the element type.
   * 
   * @return the element type.
   */
  public T getElementType();



  /**
   * Deactivate the whole panel.
   */
  public void deactivateAll();



  /**
   * Handle the common panel activation.
   * 
   * @param isActivated
   *          Whether the panel is activated.
   */
  public void activateCommon(boolean isActivated);



  /**
   * Deactivate the specific panel.
   */
  public void deactivateSpecific();



  /**
   * Deactivate the parent panel.
   */
  public void deactivateParent();



  /**
   * Update the panel border whether the element model is accepted or not.
   */
  public void updateBorder();



  /**
   * Set the displayed element.
   * 
   * @param model
   *          the displayed element model.
   */
  public void setElement(E model);



  /**
   * Update the displayed element.
   * 
   * @param updatedModel
   *          the displayed element model.
   */
  public void updateElement(E updatedModel);



  /**
   * Get the displayed element.
   * 
   * @return the displayed element model.
   */
  public E getElement();



  /**
   * The application gui.
   * 
   * @return the gui.
   */
  public G getGui();



  /**
   * Set the ID label.
   * 
   * @param id
   *          the value to display.
   */
  public void setRootElementID(String id);



  /**
   * Get the specific panel.
   * 
   * @return the specific panel.
   */
  public JPanel getSpecificPanel();



  /**
   * Get the parent panel.
   * 
   * @return the parent panel.
   */
  public ElementViewPanel<G, I, E, T> getParentPanel();



  /**
   * Set the parent panel.
   * 
   * @param panel
   *          the parent panel.
   */
  public void setParentPanel(ElementViewPanel<G, I, E, T> panel);



  /**
   * Create the popup menu.
   * 
   * @return the popup menu.
   */
  public JPopupMenu createPopupMenu();



  /**
   * Display if its needed the popup menu.
   * 
   * @param e
   *          The mouse event.
   */
  public void maybeShowPopup(MouseEvent e);



  /**
   * Display the popup.
   * 
   * @param component
   *          The component.
   * @param x
   *          The x position.
   * @param y
   *          The y position.
   */
  public void displayPopup(Component component, int x, int y);



  /**
   * Add a sub-element.
   */
  public void addSubElement();



  /**
   * Delete a sub-element.
   */
  public void deleteSubElement();



  /**
   * Move down or left a sub-element.
   */
  public void moveDownOrLeft();



  /**
   * Move up or right a sub-element.
   */
  public void moveUpOrRight();



  /**
   * Get the popup add element item.
   * 
   * @return the popup add element item.
   */
  public JMenuItem getMenuAdd();



  /**
   * Get the popup delete element item.
   * 
   * @return the popup delete element item.
   */
  public JMenuItem getMenuDelete();



  /**
   * Get the popup move down element item.
   * 
   * @return the popup move down element item.
   */
  public JMenuItem getMenuDown();



  /**
   * Get the popup move up element item.
   * 
   * @return the popup move up element item.
   */
  public JMenuItem getMenuUp();



  /**
   * Get the popup move left element item.
   * 
   * @return the popup move left element item.
   */
  public JMenuItem getMenuLeft();



  /**
   * Get the popup move right element item.
   * 
   * @return the popup move right element item.
   */
  public JMenuItem getMenuRight();



  /**
   * Get the popup menu.
   * 
   * @return the popup menu.
   */
  public JPopupMenu getPopup();



  /**
   * Get the ID label.
   * 
   * @return the ID label.
   */
  public JLabel getLabelId();



  /**
   * Get the type label.
   * 
   * @return the type label.
   */
  public JLabel getLabelType();



  /**
   * Whether the common panel is selected.
   * 
   * @return the common label is selected.
   */
  public boolean isCommonSelected();



  /**
   * Whether the common panel, or one of its sub panel is selected.
   * 
   * @return whether the common label or one of its sub panel is selected.
   */
  public boolean hasAtLeastOneCommonSelected();



  /**
   * Get the internal frame.
   * 
   * @return the internal frame.
   */
  public I getInternalFrame();



  /**
   * Get the view panel from the element or one of its sub-element.
   * 
   * @param elementUniqueID
   *          The element unique ID.
   * @return the view panel.
   */
  public ElementViewPanel<G, I, E, T> getViewPanel(UID elementUniqueID);

}
